package com.weareint.examples.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.weareint.examples.dto.ProductDTO;
import com.weareint.common.entity.AbstractEntity;
import com.weareint.common.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 *
 *
 *
 * <pre>
 *     产品
 * </pre>
 *
 * @author Auto Generator
 * @date 2021-07-16
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("product")
@ApiModel(value = "产品", description = "产品")
public class Product extends AbstractEntity<ProductDTO> {

    @ApiModelProperty(value = "名称")
    @TableField("name")
    private String name;

    @ApiModelProperty(value = "编码")
    @TableField("code")
    private String code;

    @ApiModelProperty(value = "产品类型ID")
    @TableField("prod_type_id")
    private Long prodTypeId;

    @ApiModelProperty(value = "物料ID")
    @TableField("material_id")
    private Long materialId;

    @ApiModelProperty(value = "客户ID")
    @TableField("company_id")
    private Long companyId;

    @ApiModelProperty(value = "网版ID")
    @TableField("note_id")
    private Long noteId;



    public static final String CREATE_TIME ="create_time";

    public static final String UPDATE_TIME ="update_time";

    public static final String CREATOR ="creator";

    public static final String UPDATER ="updater";

    public static final String ID ="id";

    public static final String NAME ="name";

    public static final String CODE ="code";

    public static final String PROD_TYPE_ID ="prod_type_id";

    public static final String MATERIAL_ID ="material_id";

    public static final String COMPANY_ID ="company_id";

    public static final String NOTE_ID ="note_id";


    public static final String[] COLUMNS =
            new String[] {
                    CREATE_TIME,
                    UPDATE_TIME,
                    CREATOR,
                    UPDATER,
                    ID,
                    NAME,
                    CODE,
                    PROD_TYPE_ID,
                    MATERIAL_ID,
                    COMPANY_ID,
                    NOTE_ID
            };

    /**
     *
     *
     * <pre>
     *     创建对应的DTO
     * </pre>
     * @return {@link ProductDTO}
     */
    @Override
    public ProductDTO toDTO() {
        ProductDTO dto = new ProductDTO();
        dto.setCreateTime(DateUtil.format(this.getCreateTime()));
        dto.setUpdateTime(DateUtil.format(this.getUpdateTime()));
        dto.setCreator(this.getCreator());
        dto.setUpdater(this.getUpdater());
        dto.setId(this.getId());
        dto.setName(this.getName());
        dto.setCode(this.getCode());
        dto.setProdTypeId(this.getProdTypeId());
        dto.setMaterialId(this.getMaterialId());
        dto.setCompanyId(this.getCompanyId());
        dto.setNoteId(this.getNoteId());
        return dto;
    }
}
